import React, { Component } from 'react';
import { Spin } from 'antd';
import { SimpleTable } from 'sei-antd-components';
import PageOperateHoc from 'shared/components/PageOperateHoc/index.jsx';
import CheckAuth from 'shared/components/CheckAuth/index.jsx';
import './index.less';

class Demo extends Component {
	state = {
	  loading: false,
	  selectedRows: [],
	}

	handleRowSelectChange = () => {
	}

	getTableProps = () => {
	  const { selectedRows } = this.state;
	  const columns = [
	    {
	      title: "操作",
	      width:120,
	      dataIndex: "operator",
	      render: (text, record, index) => {
	        return (
	          <div className='row-operator' onClick={(e) => {
	            e.stopPropagation()
	          }}>
              <CheckAuth
                operateCode=""
              >
                <a className='row-operator-item'
                  onClick={()=>this.editClick(record)}>
                  编辑
                </a>
              </CheckAuth>
              <CheckAuth
                operateCode=""
              >
                <a className='row-operator-item'
                  onClick={()=>this.deleteClick(record)}
                >
                  删除
                </a>
              </CheckAuth>
	          </div>
	        )
	      }
	    },
	    {
	      title: '代码',
	      dataIndex: 'code',
	      width: 60
	    },
	    {
	      title: '名称',
	      dataIndex: 'name',
	      width: 100
	    },
	    {
	      title: '描述',
	      dataIndex: 'remark',
	      width: 140
	    },
	    {
	      title: 'web服务代码',
	      dataIndex: 'webBaseAddress',
	      width: 100
	    },
	    {
	      title: 'api服务代码',
	      dataIndex: 'apiBaseAddress',
	      width: 100,
	    },
	  ];

	  return {
	    columns,
	    data: [{
        code: 11,
        name: '名称名称名称名称名称名称名称名称名称',
        remark: '名称名称名称名称名称名称名称名称名称',
        webBaseAddress: '测试',
        apiBaseAddress: 'ds'
      }],
      rowKey: 'code',
	    rowsSelected: selectedRows,
	    onSelectRow: this.handleRowSelectChange
	  }
	}

	render() {
	  const { loading } = this.state;

	  return (
	    <Spin spinning={loading} tip='加载中...'>
	      <SimpleTable {...this.getTableProps()}/>
	    </Spin>
	  );
	}
}

export default PageOperateHoc(Demo);
